package com.flying.test.vavreither;


import io.vavr.control.Either;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

public class RunWrapper {
    public static void main(String[] args) {

        computewithEither(9).swap()
                .map(s -> s)
                .forEach(System.out::println);
        Integer result = computewithEither(90)
                .fold(Integer::valueOf,Integer::intValue);
        System.out.println(result);
    }

    public static final Map<String, Object> computeWithoutEitherUsingMap(int marks) {
        Map<String, Object> results = new HashMap<>();
        if (marks < 85) {
            results.put("FAILURE", "Marks not acceptable");
        } else {
            results.put("SUCCESS", marks);
        }
        return results;
    }

    public static final Object[] computeWithoutWitherUsingArray(int marks) {
        Object[] results = new Object[2];
        if (marks < 85) {
            results[0] = "Marks not acceptable";
        } else {
            results[1] = marks;
        }
        return results;
    }

    public static final Either<String, Integer> computewithEither(int marks) {
        if (marks < 85) {
            return Either.left("Marks not acceptable");
        } else {
            return Either.right(marks);
        }
    }
}
